package com.example.mapexport.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter4.BaseQuickAdapter;
import com.chad.library.adapter4.viewholder.QuickViewHolder;
import com.example.mapexport.R;
import com.example.mapexport.realm.MyPoiItem;

public class PoiTelAdapter extends BaseQuickAdapter<String, PoiTelAdapter.MyViewHolder> {


    @NonNull
    @Override
    protected MyViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.poi_text_item, viewGroup, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i, @Nullable String s) {
        if(!TextUtils.isEmpty(s)) {
            myViewHolder.tvTel.setText(s);
        } else {
            myViewHolder.tvTel.setText("");
        }
    }


    protected class MyViewHolder extends QuickViewHolder {

        TextView tvTel;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);

            tvTel = itemView.findViewById(R.id.tvTel);
        }
    }
}
